<?php
//filename : stug.php

require_once APPPATH.'controllers/gnc_mng'.EXT;

class STUG extends Gnc_mng {
	protected $model_path = 'stu/m_stug';
	protected $detail_model_path = 'stu/m_detail_stug';
	
	//dioverride agar saat add data, status tidak ditampilkan
	protected function populate_add_content_data(&$content_data = NULL, &$external_data = NULL) {
		$mode = $external_data['add_data']['mode'];		
		
		$nav = $external_data['add_data']['nav_data'];
		
		$options = $external_data['add_data']['options'];
		
		//bagian yang dioverride
		$myquery = "select id,id_request,no_st,d_st, pjb_ttd_st, kategori_tugas, perihal_tugas,lokasi_tugas,dt_berangkat,dt_kembali,transportasi,allowance from stu_h_st"; 
		// get metadata only
		if (isset($options['type']) && (strcasecmp($options['type'], 'detail')==0)) {
			$master_data = $this->model->get_single($options['keys']);
			$data = $this->detail_model->get_from_sql($myquery, true, false); //bagian yang dioverride
			$record = array();
			foreach ($data['metadata']['keys']['foreign'][$data['metadata']['pri_table']] as $fi => $fv) {
				foreach ($fv['fk_value'] as $idx => $val) {
					if (in_array($val, $master_data['metadata']['fields_list'])) {
						$record[$idx] = $master_data['data']['current'][$val];
					}
				}
			}
			$data['data']['current'] = $record;
			
		} else {
			$data = $this->model->get_from_sql($myquery, true, false);//bagian yang dioverride
			//print_r($data);
		}

		$this->populate_add_actions($actions, $_ = array('mode' => $mode, 'content_data' => compact('nav', 'data', 'options', 'actions')));		

		if (isset($options['type']) && (strcasecmp($options['type'], 'detail')==0)) {
			$mode .= '_detail';
		}		
		
		$form = array('action' => get_unit_controller($this).'/process_'.$this->add_attr[$mode]['function'], 'attributes' => array());
		
		$content_data = compact('nav', 'options', 'data', 'actions', 'form');
	}
}
?>
